
/*
 * List of LLVM intrinsics
 *
 * INTRINS(id, llvm_id)
 *   To define a simple intrinsic
 * INTRINS_OVR(id, llvm_id)
 *   To define an overloaded intrinsic
 */

INTRINS_OVR(MEMSET, memset)
INTRINS_OVR(MEMCPY, memcpy)
INTRINS_OVR(MEMMOVE, memmove)
INTRINS_OVR(SADD_OVF_I32, sadd_with_overflow)
INTRINS_OVR(UADD_OVF_I32, uadd_with_overflow)
INTRINS_OVR(SSUB_OVF_I32, ssub_with_overflow)
INTRINS_OVR(USUB_OVF_I32, usub_with_overflow)
INTRINS_OVR(SMUL_OVF_I32, smul_with_overflow)
INTRINS_OVR(UMUL_OVF_I32, umul_with_overflow)
INTRINS_OVR(SADD_OVF_I64, sadd_with_overflow)
INTRINS_OVR(UADD_OVF_I64, uadd_with_overflow)
INTRINS_OVR(SSUB_OVF_I64, ssub_with_overflow)
INTRINS_OVR(USUB_OVF_I64, usub_with_overflow)
INTRINS_OVR(SMUL_OVF_I64, smul_with_overflow)
INTRINS_OVR(UMUL_OVF_I64, umul_with_overflow)
INTRINS_OVR(SIN, sin)
INTRINS_OVR(COS, cos)
INTRINS_OVR(SQRT, sqrt)
INTRINS_OVR(FLOOR, floor)
INTRINS_OVR(FLOORF, floor)
INTRINS_OVR(CEIL, ceil)
INTRINS_OVR(CEILF, ceil)
INTRINS_OVR(FMA, fma)
INTRINS_OVR(FMAF, fma)
	/* This isn't an intrinsic, instead llvm seems to special case it by name */
INTRINS_OVR(FABS, fabs)
INTRINS_OVR(ABSF, fabs)
INTRINS_OVR(SINF, sin)
INTRINS_OVR(COSF, cos)
INTRINS_OVR(SQRTF, sqrt)
INTRINS_OVR(POWF, pow)
INTRINS_OVR(POW, pow)
INTRINS_OVR(EXP, exp)
INTRINS_OVR(EXPF, exp)
INTRINS_OVR(LOG, log)
INTRINS_OVR(LOG2, log2)
INTRINS_OVR(LOG2F, log2)
INTRINS_OVR(LOG10, log10)
INTRINS_OVR(LOG10F, log10)
INTRINS_OVR(TRUNC, trunc)
INTRINS_OVR(TRUNCF, trunc)
INTRINS_OVR(COPYSIGN, copysign)
INTRINS_OVR(COPYSIGNF, copysign)
INTRINS_OVR(EXPECT_I8, expect)
INTRINS_OVR(EXPECT_I1, expect)
INTRINS_OVR(CTPOP_I32, ctpop)
INTRINS_OVR(CTPOP_I64, ctpop)
INTRINS_OVR(CTLZ_I32, ctlz)
INTRINS_OVR(CTLZ_I64, ctlz)
INTRINS_OVR(CTTZ_I32, cttz)
INTRINS_OVR(CTTZ_I64, cttz)
INTRINS(BZHI_I32, x86_bmi_bzhi_32)
INTRINS(BZHI_I64, x86_bmi_bzhi_64)
INTRINS(BEXTR_I32, x86_bmi_bextr_32)
INTRINS(BEXTR_I64, x86_bmi_bextr_64)
INTRINS(PEXT_I32, x86_bmi_pext_32)
INTRINS(PEXT_I64, x86_bmi_pext_64)
INTRINS(PDEP_I32, x86_bmi_pdep_32)
INTRINS(PDEP_I64, x86_bmi_pdep_64)
#if defined(TARGET_AMD64) || defined(TARGET_X86)
INTRINS(SSE_PMOVMSKB, x86_sse2_pmovmskb_128)
INTRINS(SSE_MOVMSK_PS, x86_sse_movmsk_ps)
INTRINS(SSE_MOVMSK_PD, x86_sse2_movmsk_pd)
INTRINS(SSE_PSRLI_W, x86_sse2_psrli_w)
INTRINS(SSE_PSRAI_W, x86_sse2_psrai_w)
INTRINS(SSE_PSLLI_W, x86_sse2_pslli_w)
INTRINS(SSE_PSRLI_D, x86_sse2_psrli_d)
INTRINS(SSE_PSRAI_D, x86_sse2_psrai_d)
INTRINS(SSE_PSLLI_D, x86_sse2_pslli_d)
INTRINS(SSE_PSRLI_Q, x86_sse2_psrli_q)
INTRINS(SSE_PSLLI_Q, x86_sse2_pslli_q)
INTRINS(SSE_SQRT_PD, x86_sse2_sqrt_pd)
INTRINS(SSE_SQRT_PS, x86_sse_sqrt_ps)
INTRINS(SSE_RSQRT_PS, x86_sse_rsqrt_ps)
INTRINS(SSE_RCP_PS, x86_sse_rcp_ps)
INTRINS(SSE_CVTTPD2DQ, x86_sse2_cvttpd2dq)
INTRINS(SSE_CVTTPS2DQ, x86_sse2_cvttps2dq)
INTRINS(SSE_CVTDQ2PS, x86_sse2_cvtdq2ps)
INTRINS(SSE_CVTPD2DQ, x86_sse2_cvtpd2dq)
INTRINS(SSE_CVTPS2DQ, x86_sse2_cvtps2dq)
INTRINS(SSE_CVTPD2PS, x86_sse2_cvtpd2ps)
INTRINS(SSE_CVTSS2SI, x86_sse_cvtss2si)
INTRINS(SSE_CVTSS2SI64, x86_sse_cvtss2si64)
INTRINS(SSE_CVTTSS2SI, x86_sse_cvttss2si)
INTRINS(SSE_CVTTSS2SI64, x86_sse_cvttss2si64)
INTRINS(SSE_CVTSD2SI, x86_sse2_cvtsd2si)
INTRINS(SSE_CVTSD2SI64, x86_sse2_cvtsd2si64)
INTRINS(SSE_CVTTSD2SI64, x86_sse2_cvttsd2si64)
INTRINS(SSE_CVTSI2SS, x86_sse_cvtsi2ss)
INTRINS(SSE_CVTSI2SS64, x86_sse_cvtsi642ss)
INTRINS(SSE_CVTSI2SD, x86_sse2_cvtsi2sd)
INTRINS(SSE_CVTSI2SD64, x86_sse2_cvtsi642sd)
INTRINS(SSE_CMPPD, x86_sse2_cmp_pd)
INTRINS(SSE_CMPPS, x86_sse_cmp_ps)
INTRINS(SSE_CMPSS, x86_sse_cmp_ss)
INTRINS(SSE_CMPSD, x86_sse2_cmp_sd)
INTRINS(SSE_COMIEQ_SS, x86_sse_comieq_ss)
INTRINS(SSE_COMIGT_SS, x86_sse_comigt_ss)
INTRINS(SSE_COMIGE_SS, x86_sse_comige_ss)
INTRINS(SSE_COMILT_SS, x86_sse_comilt_ss)
INTRINS(SSE_COMILE_SS, x86_sse_comile_ss)
INTRINS(SSE_COMINEQ_SS, x86_sse_comineq_ss)
INTRINS(SSE_UCOMIEQ_SS, x86_sse_ucomieq_ss)
INTRINS(SSE_UCOMIGT_SS, x86_sse_ucomigt_ss)
INTRINS(SSE_UCOMIGE_SS, x86_sse_ucomige_ss)
INTRINS(SSE_UCOMILT_SS, x86_sse_ucomilt_ss)
INTRINS(SSE_UCOMILE_SS, x86_sse_ucomile_ss)
INTRINS(SSE_UCOMINEQ_SS, x86_sse_ucomineq_ss)
INTRINS(SSE_PACKSSWB, x86_sse2_packsswb_128)
INTRINS(SSE_PACKUSWB, x86_sse2_packuswb_128)
INTRINS(SSE_PACKSSDW, x86_sse2_packssdw_128)
INTRINS(SSE_PACKUSDW, x86_sse41_packusdw)
INTRINS(SSE_MINPS, x86_sse_min_ps)
INTRINS(SSE_MAXPS, x86_sse_max_ps)
INTRINS(SSE_MINSS, x86_sse_min_ss)
INTRINS(SSE_MAXSS, x86_sse_max_ss)
INTRINS(SSE_HADDPS, x86_sse3_hadd_ps)
INTRINS(SSE_HSUBPS, x86_sse3_hsub_ps)
INTRINS(SSE_ADDSUBPS, x86_sse3_addsub_ps)
INTRINS(SSE_MINPD, x86_sse2_min_pd)
INTRINS(SSE_MAXPD, x86_sse2_max_pd)
INTRINS(SSE_HADDPD, x86_sse3_hadd_pd)
INTRINS(SSE_HSUBPD, x86_sse3_hsub_pd)
INTRINS(SSE_ADDSUBPD, x86_sse3_addsub_pd)
INTRINS(SSE_PADDSW, x86_sse2_padds_w)
INTRINS(SSE_PSUBSW, x86_sse2_psubs_w)
INTRINS(SSE_PADDUSW, x86_sse2_paddus_w)
INTRINS(SSE_PSUBUSW, x86_sse2_psubus_w)
INTRINS(SSE_PMULHW, x86_sse2_pmulh_w)
INTRINS(SSE_PMULHU, x86_sse2_pmulhu_w)
INTRINS(SSE_PADDSB, x86_sse2_padds_b)
INTRINS(SSE_PSUBSB, x86_sse2_psubs_b)
INTRINS(SSE_PADDUSB, x86_sse2_paddus_b)
INTRINS(SSE_PSUBUSB, x86_sse2_psubus_b)
INTRINS(SSE_PAUSE, x86_sse2_pause)
INTRINS(SSE_PSHUFB, x86_ssse3_pshuf_b_128)
INTRINS(SSE_DPPS, x86_sse41_dpps)
INTRINS(SSE_ROUNDSS, x86_sse41_round_ss)
INTRINS(SSE_ROUNDPD, x86_sse41_round_pd)
INTRINS(SSE_PTESTZ, x86_sse41_ptestz)
INTRINS(SSE_INSERTPS, x86_sse41_insertps)
#if LLVM_API_VERSION >= 800
	// these intrinsics were renamed in LLVM 8
INTRINS_OVR(SSE_SADD_SATI8, sadd_sat)
INTRINS_OVR(SSE_UADD_SATI8, uadd_sat)
INTRINS_OVR(SSE_SADD_SATI16, sadd_sat)
INTRINS_OVR(SSE_UADD_SATI16, uadd_sat)
#else
INTRINS(SSE_SADD_SATI8, x86_sse2_padds_b)
INTRINS(SSE_UADD_SATI8, x86_sse2_paddus_b)
INTRINS(SSE_SADD_SATI16, x86_sse2_padds_w)
INTRINS(SSE_UADD_SATI16, x86_sse2_paddus_w)
#endif
#endif
#if defined(TARGET_WASM) && LLVM_API_VERSION >= 800
INTRINS_OVR(WASM_ANYTRUE_V16, wasm_anytrue)
INTRINS_OVR(WASM_ANYTRUE_V8, wasm_anytrue)
INTRINS_OVR(WASM_ANYTRUE_V4, wasm_anytrue)
INTRINS_OVR(WASM_ANYTRUE_V2, wasm_anytrue)
#endif

#undef INTRINS
#undef INTRINS_OVR

